package com.qf.dao.blog.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qf.api.blog.entity.ArticleEntity;
import com.qf.api.blog.vo.ArticlePageVO;
import com.qf.api.front.dto.ArticleContent;
import com.qf.api.front.vo.ArticleVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
* @author sin
* @description 针对表【t_article(文章表)】的数据库操作Mapper
* @createDate 2025-05-23 13:27:40
* @Entity com.qf.api.entity.TArticle
*/
@Mapper
public interface ArticleMapper extends BaseMapper<ArticleEntity> {
    List<ArticlePageVO> getArticlePage(@Param("tagId") Integer tagId, @Param("categoryId") Integer categoryId, @Param("articleTitle") String articleTitle, @Param("isTop") Integer isTop, @Param("status") Integer status);

    // 修改文章置顶状态
    @Update("UPDATE t_article SET is_top = #{value} WHERE id = #{articleId}")
    void updateArticleTop(@Param("articleId") Long articleId, @Param("value") Integer value);

    // 修改文章状态
    @Update("UPDATE t_article SET status = #{value} WHERE id = #{articleId}")
    void updateArticleStatus(@Param("articleId") Long articleId, @Param("value") Integer value);

    @Select("SELECT * FROM t_article WHERE title = #{title}")
    ArticleEntity selectByTitle(@Param("title") String title);

    @Select("SELECT SUM(word_count) FROM t_article")
    long getWordCount();

    List<ArticleVO> getPageArticle(@Param("title") String title, @Param("tagId") Long tagId, @Param("categoryId") Long categoryId);

    ArticleContent getArticleContent(Long articleId);
}




